//
//  TXTabBarViewController.swift
//  MicroBlog
//
//  Created by Jokin on 2017/3/26.
//  Copyright © 2017年 jokin. All rights reserved.
//

import UIKit

class TXTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildVC(viewcontroller: HomeTableViewController(), image: "tabbar_home", title: "首页")
        addChildVC(viewcontroller: MassageTableViewController(), image: "tabbar_message_center", title: "消息")
        addChildVC(viewcontroller: DiscoverTableViewController(), image: "tabbar_discover", title: "发现")
        addChildVC(viewcontroller: MineTableViewController(), image: "tabbar_profile", title: "我的")
        let TXtabbar = TXTabbar()
        
        self.setValue(TXtabbar, forKey: "tabBar")
        
        
    }
    
    
    
    
  
    func addChildVC(viewcontroller:UIViewController, image:String, title: String) {
        
        viewcontroller.tabBarItem.image = UIImage(named: image)
        
        viewcontroller.tabBarItem.selectedImage = UIImage(named: image + "_selected")?.withRenderingMode(.alwaysOriginal)
        viewcontroller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orange], for: .selected)
        viewcontroller.tabBarItem.setTitleTextAttributes([NSFontAttributeName: UIFont.systemFont(ofSize: 10)], for: .normal)
        
        viewcontroller.title = title
        let navVC = TXNavViewController(rootViewController: viewcontroller)
        
        addChildViewController(navVC)
        
        
 
    }
    
    


}
